package com.bruan.d10_methodreference;

import com.bruan.d8_arrays.Student;

import java.util.Arrays;
import java.util.Comparator;

public class Test {
    public static void main(String[] args) {
        Student[] arrays = new Student[6];
        arrays[0] = new Student("xxx",11,"1232312");
        arrays[1] = new Student("xxx",12,"1232312");
        arrays[2] = new Student("xxx",13,"1232312");
        arrays[3] = new Student("xxx",42,"1232312");
        arrays[4] = new Student("xxx",33,"1232312");
        arrays[5] = new Student("xxx",1,"1232312");
        //lambda表达式
//        Arrays.sort(arrays,(o1, o2) ->
//            o1.getAge() - o2.getAge()
//        );
        //调用封装的类方法
        Arrays.sort(arrays,(o1,o2)->CompareByData.CompareByAge(o1,o2));
        //静态代码引用
        Arrays.sort(arrays,CompareByData::CompareByAge);
        System.out.println(Arrays.toString(arrays));

    }
}
